const state = {
  categoryList: [],
  carId: '',
}

const mutations = {
  // 存储类别列表
  GETCATEGORY(state, value) {
    state.categoryList = value
  },
  // 存储分类第一条数据的id
  GETCARDID(state, value) {
    state.carId = value
  },
}

const actions = {
  // 获取所有类别
  async getCategory({ commit }) {
    const ret = await reqCategory()
    if (ret.code == 200) commit('GETCATEGORY', ret.data)
  },
  // 获取分类第一条数据的id
  async getCardId({ commit }) {
    let ret = await reqCarId()
    if (ret.code == 200) commit('GETCARDID', ret.data._id)
  },
}

//计算属性
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
}
